package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 请求头限定
 * @author stone
 * @date 2022/08/06 10:07
 */
@Controller
@RequestMapping("header")
public class HeaderController {

    // localhost:8080/header/limit
    // headers = {"abc","def"} 含义是要有abc和def这两个请求头 and
    @RequestMapping(value = "limit",headers = {"abc","def"})
    @ResponseBody
    public BaseRespVo headerLimit() {
        return BaseRespVo.ok("header limit");
    }

    // 多个值之间的关系是or
    @RequestMapping(value = "consumes",consumes = "abc/def")
    @ResponseBody
    public BaseRespVo contentType() {
        return BaseRespVo.ok("ContentType请求头的值的限定");
    }

    // 多个值之间的关系是or
    //@RequestMapping(value = "produces",produces = "def/abc")
    @RequestMapping(value = "produces",produces = "application/json")
    @ResponseBody
    public BaseRespVo accept() {
        return BaseRespVo.ok("Accept请求头的值的限定");
    }
}
